package me.greyliu.kuai.dao;

import me.greyliu.kuai.App;
import me.greyliu.kuai.entity.Share;
import me.greyliu.kuai.entity.User;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class ShareDao {
    public Share getShareByID(String id){
        try {
            Statement stmt = App.c.createStatement();
            ResultSet rs = stmt.executeQuery( "SELECT * FROM SHARE WHERE ID='"+id+"';" );
            rs.next();
            String  user = rs.getString("user");
            String path = rs.getString("path");
            String name = rs.getString("name");
            String pwd = rs.getString("pwd");
            rs.close();
            stmt.close();
            if(name!=null)
                return new Share(id,user,path,name,pwd);
        }catch( Exception e ) {
            System.err.println( e.getClass().getName() + ": " + e.getMessage() );
        }
        return null;
    }
}
